package com.nowcoder.code.hjnc;

import java.util.PriorityQueue;
import java.util.Scanner;

public class HJ01 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        String[] ss = input.split(",");
        System.out.println(test(ss));

    }


    public static String test(String[] ss) {

        PriorityQueue<String> priorityQueue = new PriorityQueue<>(4, (o1, o2) -> {
            if (o1.length() > o2.length()) {
                return -1;
            } else if (o1.length() < o2.length()) {
                return 1;
            }
            for (int i = 0; i < o1.length(); i++) {
                if (o1.charAt(i) > o2.charAt(i)) {
                    return -1;
                } else if (o1.charAt(i) < o2.charAt(i)) {
                    return 1;
                }
            }
            return 0;
        });

        for (String s : ss) {
            priorityQueue.add(s);
            if (priorityQueue.size() == 4) {
                priorityQueue.poll();
            }
        }
        StringBuilder sb = new StringBuilder();

        PriorityQueue<String> priorityQueue1 = new PriorityQueue<>(priorityQueue.size(), (o1, o2) -> {
            if (o1.length() > o2.length()) {
                o2 = o2 + (10 * (o1.length() - o2.length()));

            } else if (o1.length() < o2.length()) {
                o1 = o1 + (10 * (o2.length() - o1.length()));
            }
            for (int i = 0; i < o1.length(); i++) {
                if (o1.charAt(i) > o2.charAt(i)) {
                    return -1;
                } else if (o1.charAt(i) < o2.charAt(i)) {
                    return 1;
                }
            }
            return 0;
        });
        priorityQueue1.addAll(priorityQueue);
        while (priorityQueue1.size() != 0) {
            sb.insert(0, priorityQueue1.poll());
        }

        return sb.toString();
    }
}
